package cn.dz.beans;

import cn.dz.dao.UserDao;
import cn.dz.service.UserService;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

/**
 * @ClassName OtherBean
 * @package: cn.dz.beans
 * @Description TODO
 * @Author dz
 * @Date 2025/2/10 16:48
 * @Version 1.0
 **/
@Component
public class OtherBean {

    @Bean("dataSource")
    public DataSource dataSource(
            @Value("${jdbc.driver}") String driverClassName,
            @Qualifier("userDao") UserDao userDao,
            @Autowired UserService userService
            ) {
        System.out.println(driverClassName);
        System.out.println(userDao);
        System.out.println(userService);
        DruidDataSource dataSource = new DruidDataSource();
        //设置4个基本参数...
        dataSource.setDriverClassName(driverClassName);
        return dataSource;
    }
}
